-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: log process id instead of logging name #2100
Conversation
5dc5655
to
059c756
Compare
cni/log/logger.go
Outdated
@@ -46,6 +47,7 @@ func newFileLogger(cfg *Config) *zap.Logger { | |||
|
|||
core := zapcore.NewCore(jsonEncoder, logFileWriter, logLevel) | |||
Logger = zap.New(core) | |||
Logger = Logger.With(zap.Int("pid", os.Getgid())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.Getgid()
will return -1 for windows.
Also, since we are removing components name from log and now the cfg.Name
as well. How will the log look like ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Vipul, you can see current log as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"level":"info","ts":"2023-08-02T02:38:03.651Z","msg":"Plugin stopped","pid":0,"component":"cni-net"}
, the component will be remove as per PR#2099. So the log will be {"level":"info","ts":"2023-08-02T02:38:03.651Z","msg":"Plugin stopped","pid":0,"}
? If so, how would we know that which plugin stopped ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think removing the component (#2099) is a mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rbtr As Tamilmani mentioned that CNI is mostly single threaded, so adding the component in each log is not that helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't matter that it is single threaded.
extra log context is meant to help you identify where in the code the log (or probably error) is coming from. "component" should describe the specific module of the CNI that is generating that log, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can keep component if you guys say so. but based on my debugging experince, i never looked at component in log.
@paulyufan2 the way you are getting pid is wrong. @vipul-21 each plugin will have different log file.. if azure-vnet.log, then cni plugin, if azure-vnet-ipam.log, then its ipam plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulyufan2 Let's keep component for now and review back later. you can abandon this PR and create a PR for adding PID and remove logger name
186ccfd
to
6c6ef47
Compare
6c6ef47
to
d589d7d
Compare
cni/log/logger.go
Outdated
|
||
return Logger.Named(cfg.Name) | ||
return Logger.Named("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to return the Logger.Named(""). We can now just return the Logger
. By default Logger is unnamed.
f138991
to
8176a4f
Compare
* get rid of logger name * change to getpid() * fix comment
* get rid of logger name * change to getpid() * fix comment
* get rid of logger name * change to getpid() * fix comment
Reason for Change:
This PR is to get rid of repeated "logger: azure-vnet" name. Instead, it will print the process id, such as : "pid":301
Issue Fixed:
New logs on Linux:
New logs on Windows:
{"level":"info","ts":"2023-08-11T02:27:30.090Z","msg":"Plugin started","pid":5112,"component":"cni-net"}
{"level":"info","ts":"2023-08-11T02:27:30.090Z","msg":"[cni-net] Processing DEL command","pid":5112,"containerId":"a02bd997aaec32e8356286bc6411eb7ba6ed273bf7140716eacf35965233e46a","netNS":"c46f1949-30b1-4d44-be62-6ac58263d28c","ifName":"eth0","args":"IgnoreUnknown=1;K8S_POD_NAMESPACE=kube-system;K8S_POD_NAME=csi-azurefile-node-win-5xrfh;K8S_POD_INFRA_CONTAINER_ID=a02bd997aaec32e8356286bc6411eb7ba6ed273bf7140716eacf35965233e46a;K8S_POD_UID=e9aa3235-0205-4372-871e-56ada83c6ae0","path":"c:/k/azurecni/bin","stdinData":"{"AdditionalArgs":[{"Name":"EndpointPolicy","Value":{"ExceptionList":["10.244.0.0/16"],"Type":"OutBoundNAT"}},{"Name":"EndpointPolicy","Value":{"ExceptionList":["fdad:db03:a8b6:1a06::/64"],"Type":"OutBoundNAT"}},{"Name":"EndpointPolicy","Value":{"Action":"Block","Direction":"Out","Priority":200,"Protocols":"6","RemoteAddresses":"168.63.129.16/32","RemotePorts":"80","RuleType":"Switch","Type":"ACL"}},{"Name":"EndpointPolicy","Value":{"Action":"Allow","Direction":"In","Priority":65500,"Type":"ACL"}},{"Name":"EndpointPolicy","Value":{"Action":"Allow","Direction":"Out","Priority":65500,"Type":"ACL"}}],"bridge":"azure0","capabilities":{"dns":true,"portMappings":true},"cniVersion":"0.3.0","dns":{"Nameservers":["10.0.0.10","168.63.129.16"],"Search":["svc.cluster.local"]},"executionMode":"v4swift","ipam":{"mode":"v4overlay","type":"azure-cns"},"mode":"bridge","name":"azure","runtimeConfig":{"dns":{"Servers":["10.0.0.10"],"Searches":["kube-system.svc.cluster.local","svc.cluster.local","cluster.local"],"Options":["ndots:5"]}},"type":"azure-vnet","windowsSettings":{"enableLoopbackDSR":true}}"}
{"level":"info","ts":"2023-08-11T02:27:30.091Z","msg":"Execution mode","pid":5112,"mode":"v4swift"}
{"level":"info","ts":"2023-08-11T02:27:30.091Z","msg":"[cni-net] Endpoints to be deleted","pid":5112,"count":1}
{"level":"error","ts":"2023-08-11T02:27:30.091Z","msg":"[cni-net] Failed to query network","pid":5112,"network":"azure","error":"Network not found"}
{"level":"info","ts":"2023-08-11T02:27:30.091Z","msg":"[cni-net] DEL command completed","pid":5112,"pod":"csi-azurefile-node-win-5xrfh"}
{"level":"info","ts":"2023-08-11T02:27:30.091Z","msg":"Plugin stopped","pid":5112,"component":"cni-net"}
2023/08/11 02:27:30 [5112] Released process lock
the nonsense <"logger": "azure-vnet"> is gone and "pid": is added
Requirements:
Notes: